package com.lp.chapter001.pool;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Easypoi导入线程池
 * @author LP to 2024/03/01
 */
@Configuration
public class EasypoiImportThreadPool {

    @Bean(name = "easypoiStudentImportThreadPool")
    public ThreadPoolExecutor easypoiStudentImportThreadPool() {
        // 系统可用处理器的虚拟机数量
        int processors = Runtime.getRuntime().availableProcessors();
        return new ThreadPoolExecutor(processors + 1,
                processors * 2 + 1,
                10 * 60,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(1000000));
    }
}
